package com.econ.powercloud.ems.common.enums;

import java.util.Objects;

/**
 * @Author : zjf
 * @Description : 实时数据对应的位置枚举
 * 这里的code之所以是不连续的，是因为版本在更新的时候，部分数据已不再存放在这里
 * @Date : 2021/11/19 8:57
 * @Modified by : zjf
 */
public enum LocationUrl implements EnumMethod {
    //遥测数据分类
    TWO_DIMENSIONAL_YC(1,"遥测(二维)",DimensionalType.TWO_DIMENSIONAL,DitTypeEnum.YC),
    /**
     * 簇单元体的顺序是固定的,顺序分别是SOC,总电压,总电流,最高压,最低压,最高温度,最低温度
     */
    ONE_DIMENSIONAL_YC(2,"簇单元体/空调/液冷/控制器遥测数据(一维)",DimensionalType.ONE_DIMENSIONAL,DitTypeEnum.YC),
    CONTROL_GROUP_ONE_YC(3,"控制器组1遥测数据",DimensionalType.ONE_DIMENSIONAL,DitTypeEnum.YC),
    CONTROL_GROUP_TWO_YC(4,"控制器组2遥测数据",DimensionalType.ONE_DIMENSIONAL,DitTypeEnum.YC),

    //遥信数据分类
    STATE_YX(5,"状态量遥信",DimensionalType.ONE_DIMENSIONAL,DitTypeEnum.YX),
    FAULT_YX(6,"故障遥信",DimensionalType.ONE_DIMENSIONAL,DitTypeEnum.YX),
    ALARM_YX(7,"告警遥信",DimensionalType.ONE_DIMENSIONAL,DitTypeEnum.YX),
    PROTECT_EVENT_YX(8,"保护事件遥信",DimensionalType.ONE_DIMENSIONAL,DitTypeEnum.YX),
    ;

    private Integer code;
    private String desc;
    private DimensionalType dimensionalType;
    private DitTypeEnum ditTypeEnum;

    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public String getDesc() {
        return desc;
    }

    public DitTypeEnum getDitTypeEnum() {
        return ditTypeEnum;
    }

    public DimensionalType getDimensionalType() {
        return dimensionalType;
    }

    LocationUrl(int code, String desc, DimensionalType dimensionalType,DitTypeEnum ditTypeEnum){
        this.code=code;
        this.desc=desc;
        this.dimensionalType=dimensionalType;
        this.ditTypeEnum=ditTypeEnum;
    }

    public static LocationUrl fromCode(Integer code){
        for(LocationUrl type: LocationUrl.values()){
            if(Objects.equals(type.getCode(),code)){
                return type;
            }
        }
        return null;
    }

    public static Integer fromDesc(String desc){
        for(LocationUrl type: LocationUrl.values()){
            if(type.getDesc().equals(desc)){
                return type.getCode();
            }
        }
        return null;
    }

}
